package com.hezuti.util;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class HttpDownload {
	
	public static String getContent(String url,String encode){
		InputStream in=null;
		try {
			URL u=new URL(url);
			in = u.openStream();
			byte[] b=new byte[1024];
			int len=-1;
			StringBuffer sb=new StringBuffer();
			while(-1!=(len=in.read(b))){
				sb.append(new String(b,0,len,encode));
			}
			return sb.toString();
		} catch (IOException e) {
			System.out.println("notfound!!");
		}finally{
			if(in!=null){
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			}
		}
		
		return null;
	}

}
